package com.isprint.jslx.sqlmapper;

import com.jfinal.config.Plugins;
import com.kabao.ext.plugin.sqlinxml.SqlInXmlPlugin;
import com.kabao.ext.plugin.sqlinxml.SqlKit;

import java.io.File;
import java.io.FileFilter;

/**
 * Created by ydw on 2017/7/14.
 */
public class SqlMapperProperties {
    public static void sqlMapper(Plugins plugins){
//        sql映射插件
        SqlInXmlPlugin sqlInXmlPlugin = new SqlInXmlPlugin();
        plugins.add(sqlInXmlPlugin);
        System.out.println("--sqlinXmlPlugin plugin added");
//        添加映射
        File file = new File(SqlKit.class.getClassLoader().getResource("").getFile());
        File[] files = file.listFiles(new FileFilter() {
            public boolean accept(File pathname) {
                if (pathname.getName().endsWith("sql.xml")) {
                    return true;
                }
                return false;
            }
        });

        System.out.println("---------load sql resource files-----------");
        try {
            for (File xmlfile : files) {
                System.out.println(xmlfile.getPath());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
